<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
    <title>天气案例</title>
</head>

<body>
    <div id="root">
        <h1>今天天气很{{info}}</h1>
        <!-- 绑定事件@xxxx="yyy"   yyy可以写为简单的语句 -->
        <!-- <button @click="tianqi = !tianqi">修改天气</button> -->
        <button @click="update">修改天气</button>
    </div>
    <script>
        new Vue({
            el: '#root',
            data: {
                tianqi: true
            },
            methods: {
                update() {
                    //   alert("1")
                    this.tianqi = !this.tianqi;

                    console.log("原来来的天气很" + this.info + ",现在天气很" + this.info)
                }
            },
            computed: {
                info() {
                    return this.tianqi ? "炎热" : "寒冷"
                }
            }
        })
    </script>
</body>

</html>